/*
 * @lc app=leetcode id=11 lang=cpp
 *
 * [11] Container With Most Water
 */
class Solution {
public:
    int maxArea(vector<int>& height) {

        int len = height.size();
        if (len < 2) {
            return 0;
        }

        int i = 0, j = len-1;
        int max = INT_MIN;
        while(i<j) {
            int h = std::min(height[i], height[j]);
            max = std::max(max, h*(j-i));
            while(i<j && height[i]<=h) i++;
            while(i<j && height[j]<=h) j--;
        }
        return max;
    }
};

